package POJO;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "STORE", uniqueConstraints = {
		@UniqueConstraint(columnNames = "Store_Id"),
		@UniqueConstraint(columnNames = "Store_Name")
})
public class Store implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8414794945696338945L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "Store_Id", unique = true, nullable = false)
	private int storeId;
	
	@Column(name = "Store_Name", unique = true, nullable = false)
	private String storeName;
	
	@Column(name = "Address")
	private String address;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.productDetail", cascade=CascadeType.ALL)
	private Set<StoreProductDetail> storeProductDetails = new HashSet<StoreProductDetail>();

	public Store() {
		super();
	}

	public Store(String storeName, String address) {
		super();
		this.storeName = storeName;
		this.address = address;
	}

	public Store(String storeName, String address,
			Set<StoreProductDetail> storeProductDetails) {
		super();
		this.storeName = storeName;
		this.address = address;
		this.storeProductDetails = storeProductDetails;
	}

	public int getStoreId() {
		return storeId;
	}

	public void setStoreId(int storeId) {
		this.storeId = storeId;
	}

	public String getStoreName() {
		return storeName;
	}

	public void setStoreName(String storeName) {
		this.storeName = storeName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Set<StoreProductDetail> getStoreProductDetails() {
		return storeProductDetails;
	}

	public void setStoreProductDetails(Set<StoreProductDetail> storeProductDetails) {
		this.storeProductDetails = storeProductDetails;
	}
}





